package annotation;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * 注解扫描
 * 解析 @ComponentScan 指定包路径
 * @see org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider#scanCandidateComponents(String)
 *
 * @see org.springframework.context.annotation.ConfigurationClassPostProcessor
 * @author jackcfan
 * @date 2021/10/1
 */
@ComponentScan("annotation")
public class ComponentScanTest {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();

        applicationContext.register(ComponentScanTest.class);
        applicationContext.refresh();

        TestClass testClass = applicationContext.getBean(TestClass.class);
        System.out.println(testClass);

        applicationContext.close();
    }
}
